package logic

import (
	"context"
	"ewaimai/waimairpc/models"

	"ewaimai/waimairpc/internal/svc"
	"ewaimai/waimairpc/waimairpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type YouhuiAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewYouhuiAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *YouhuiAddLogic {
	return &YouhuiAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *YouhuiAddLogic) YouhuiAdd(in *waimairpc.YouhuiAddRequest) (*waimairpc.YouhuiAddResponse, error) {
	// todo: add your logic here and delete this line
	var y models.You
	y.Fa = in.Fa
	y.Give = in.Give
	y.Use = in.Use
	if err := y.Create(); err != nil {
		logx.Errorf("添加失败")
	}
	return &waimairpc.YouhuiAddResponse{
		Id: int64(y.ID),
	}, nil
}
